/** * This program finds the transpose of a matrix entered by the user. * The main method asks for the user to enter a matrix, and then calls * transpose() to do the transposition. The result matrix is then * printed. */ class Transpose { public static void main (String[] args) { // DECLARE VARIABLES/DATA DICTIONARY int[][] a; // A matrix of integers int nRows; // Number of rows in a. int nCols; // Number of columns in a. int[][] at; // Transpose of a // PRINT OUT IDENTIFICATION INFORMATION System.out.println(); System.out.println("ITI 1120 Fall 2006, Lab 10, Example 2"); System.out.println("Name: Diana Inkpen, Student# 123456"); System.out.println(); // READ IN GIVENS System.out.println( "Enter the number of rows in matrix A: " ); nRows = ITI1120.readInt( ); System.out.println( "Enter the number of columns in matrix A: " ); nCols = ITI1120.readInt( ); a = MatrixLib.readIntMatrix( nRows, nCols ); // BODY OF ALGORITHM at = transpose( a ); // PRINT OUT RESULTS AND MODIFIEDS System.out.println( ); System.out.println( "The transposed matrix AT is: " ); System.out.println( ); MatrixLib.printMatrix( at ); } // If the 'main' method calls other algorithms, put the method(s) below. /** * This method transposes matrix 'a', returning matrix 'at'. * * Matrix a is assumed to be rectangular. The dimensions are not passed * as parameters; instead, the dimensions are determined from the * array lengths. * * GIVENS: a: an nRows x nCols matrix containing integers * To be completed */ public static int[][] transpose( int[][] a ) { // DECLARE VARIABLES / DATA DICTIONARY // BODY OF ALGORITHM // RETURN RESULT } }